package com.quwan.security;

import org.springframework.security.crypto.password.PasswordEncoder;

/**
 *  覆盖Spring.Security包中的NoOpPasswordEncoder类
 * Spring.Security包中的同名类做已过期处理，但目前项目中确实不需要对密码进行加密认证
 * @author quan
 * @date 2021-06-07 22:11
 */

public class NoOpPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        return rawPassword.toString();
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        return rawPassword.toString().equals(encodedPassword);
    }

    private static class Pw{
        private static PasswordEncoder passwordEncoder = new NoOpPasswordEncoder();
    }

    public static PasswordEncoder getInstance() {
        return Pw.passwordEncoder;
    }
    private NoOpPasswordEncoder() {
    }
}
